<include file="public@header"/>
</head>
<body>
<div class="wrap js-check-wrap">
    <ul class="nav nav-tabs">
        <li><a href="{:url('record/index')}">所有积分记录</a></li>
		<li><a href="{:url('record/add')}">添加积分记录</a></li>
        <li  class="active"><a href="{:url('record/edit')}">编辑积分记录</a></li>
    </ul>
    <form class="form-horizontal js-ajax-form margin-top-20" action="{:url('record/editPost')}" method="post">
        <div class="form-group">
            <label for="input-name" class="col-sm-2 control-label">头像:</label>
            <div class="col-md-6 col-sm-10">
                <input id="photo-1" type="hidden" name="picture" value="{$record.picture}">
                <input id="photo-1-name" type="text" name="photo_name" title="图片名称" value="{$record.picture}">
                <img src="__ROOT__/upload/{$record.picture}" width="50px" height="50px" id="photo-1-preview">
                <a href="javascript:uploadOneImage('图片上传','#photo-1');" id="picture">重新上传</a>
            </div>
        </div>
        <div class="form-group">
            <label for="input-name" class="col-sm-2 control-label">学校名称:</label>
            <div class="col-md-6 col-sm-10">
                <select id="selectSchool" lay-filter="selectSchool" style="width:100%">
                    <foreach name="school" item="vo">
                        <if $record.school_id == $vo.id>
                            <option value="{$vo.id}" selected>{$vo.name}</option>
                        <else />
                            <option value="{$vo.id}">{$vo.name}</option>
                        </if>
                    </foreach>
                </select>
            </div>
        </div>
        <div class="form-group">
            <label for="input-name" class="col-sm-2 control-label">班级名称:</label>
            <div class="col-md-6 col-sm-10">
                <select id="selectRoom" style="width:100%">
                    <foreach name="room" item="vo">
                        <if $record.room_id == $vo.id>
                            <option value="{$vo.id}" selected>{$vo.name}</option>
                        <else />
                            <option value="{$vo.id}">{$vo.name}</option>
                        </if>
                    </foreach>
                </select>
            </div>
        </div>
        <div class="form-group">
            <label for="input-name" class="col-sm-2 control-label">学生姓名:</label>
            <div class="col-md-6 col-sm-10">
                <select name="student_id" id="student_id" class="valid" lay-filter="student_id" style="width:100%">
                    <foreach name="student" item="vo">
                        <if $record.student_id == $vo.id>
                            <option value="{$vo.id}" selected>{$vo.name}</option>
                            <else />
                            <option value="{$vo.id}">{$vo.name}</option>
                        </if>
                    </foreach>
                </select>
            </div>
        </div>
        <div class="form-group">
            <label for="input-name" class="col-sm-2 control-label">操作员姓名:</label>
            <div class="col-md-6 col-sm-10">
                <input type="text" class="form-control" id="input-name" readonly="true" name="user_id" value="{$user.user_name}">
            </div>
        </div>
        <div class="form-group">
            <label for="input-name" class="col-sm-2 control-label">原因名称:</label>
            <div class="col-md-6 col-sm-10">
                <select name="reason_id" id="reason_id" class="valid" lay-filter="reason_id" style="width:100%">
                    <volist name="reason" id="vo">
                        <if $record.reason_id == $vo.id>
                            <option value="{$vo.id}" selected>{$vo.name}</option>
                            <else />
                            <option value="{$vo.id}">{$vo.name}</option>
                        </if>
                    </volist>
                </select>
            </div>
        </div>
        <div class="form-group">
            <label for="input-name" class="col-sm-2 control-label">积分名称:</label>
            <div class="col-md-6 col-sm-10">
                <select name="score_id" id="score_id" class="valid" lay-filter="score_id" style="width:100%">
                    <volist name="score" id="vo">
                        <if $record.score_id == $vo.id>
                            <option value="{$vo.id}" selected>{$vo.name}</option>
                            <else />
                            <option value="{$vo.id}">{$vo.name}</option>
                        </if>
                    </volist>
                </select>
            </div>
        </div>
        <div class="form-group">
            <div class="col-sm-offset-2 col-sm-10">
                <input type="hidden" name="id" value="{$record.id}"/>
                <button type="submit" class="btn btn-primary js-ajax-submit">{:lang('EDIT')}</button>
                <a class="btn btn-default" href="{:url('admin/record/index')}">{:lang('BACK')}</a>
            </div>
        </div>
    </form>
</div>
<script src="__STATIC__/js/admin.js"></script>
<script src="__STATIC__/layui/layui.all.js"></script>
<script>
    $(function () {
        $('#selectSchool').change('click',function () {
            var schoolId=$('#selectSchool').val();
            $.ajax({
                url:"{:url('student/getRoom')}",
                type:"POST",
                data:{schoolId:schoolId},
                success:function (res) {
                    $('#selectRoom').html(res);
                }
            });
        });
    });
    $(function () {
        $('#selectRoom').change('click',function () {
            var roomId=$('#selectRoom').val();
            $.ajax({
                url:"{:url('record/getStudent')}",
                type:"POST",
                data:{roomId:roomId},
                success:function (res) {
                    $('#student_id').html(res);
                }
            });
        });
    })   
</script>
</body>
</html>